home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / etc / init.d / bootlogd < prev    next >
Text File  |  2009-09-07  |  2KB  |  97 lines

  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides:          bootlogd
  4. # Required-Start:    mountdevsubfs
  5. # X-Start-Before:    hostname keymap keyboard-setup procps pcmcia hwclock hwclockfirst hdparm hibernate-clean
  6. # Required-Stop:
  7. # Default-Start:     S
  8. # Default-Stop:
  9. # Short-Description: Start or stop bootlogd.
  10. # Description:       Starts or stops the bootlogd log program
  11. #                    which logs boot messages.
  12. ### END INIT INFO
  13.  
  14. PATH=/sbin:/bin  # No remote fs at start
  15. DAEMON=/sbin/bootlogd
  16. [ -x "$DAEMON" ] || exit 0
  17. NAME=bootlogd
  18. DESC="boot logger"
  19. BOOTLOGD_OPTS="-r -c"
  20. [ -r /etc/default/bootlogd ] && . /etc/default/bootlogd
  21. . /lib/init/vars.sh
  22.  
  23. . /lib/lsb/init-functions
  24.  
  25. # Because bootlogd is broken on some systems, we take the special measure
  26. # of requiring it to be enabled by setting an environment variable.
  27. case "$BOOTLOGD_ENABLE" in
  28.   [Nn]*)
  29.     exit 0
  30.     ;;
  31. esac
  32.  
  33. # Previously this script was symlinked as "stop-bootlogd" which, when run
  34. # with the "start" argument, should stop bootlogd.  Now stop-bootlogd is
  35. # a distinct script, but for backward compatibility this script continues
  36. # to implement the old behavior.
  37. SCRIPTNAME=${0##*/}
  38. SCRIPTNAME=${SCRIPTNAME#[SK]??}
  39. ACTION="$1"
  40. case "$0" in
  41.   *stop-bootlog*)
  42.     [ "$ACTION" = start ] && ACTION=stop
  43.     ;;
  44. esac
  45.  
  46. case "$ACTION" in
  47.   start)
  48.       # PATH is set above
  49.     log_daemon_msg "Starting $DESC" "$NAME"
  50.     if [ -d /proc/1/. ]
  51.     then
  52.         umask 027
  53.         start-stop-daemon --start --quiet --exec $DAEMON -- \
  54.             $BOOTLOGD_OPTS
  55.         ES=$?
  56.     else
  57.         $DAEMON $BOOTLOGD_OPTS
  58.         ES=$?
  59.     fi
  60.     log_end_msg $ES
  61.     ;;
  62.   stop)
  63.     PATH=/bin:/sbin:/usr/bin:/usr/sbin
  64.     log_daemon_msg "Stopping $DESC" "$NAME"
  65.     start-stop-daemon --oknodo --stop --quiet --exec $DAEMON
  66.     ES=$?
  67.     sleep 1
  68.     log_end_msg $ES
  69.     if [ -f /var/log/boot ] && [ -f /var/log/boot~ ]
  70.     then
  71.         [ "$VERBOSE" = no ] || log_action_begin_msg "Moving boot log file"
  72.         # bootlogd writes to boot, making backup at boot~
  73.         cd /var/log && {
  74.             chgrp adm boot || :
  75.             savelog -q -p -c 5 boot \
  76.             && mv boot.0 boot \
  77.             && mv boot~ boot.0
  78.         }
  79.         ES=$?
  80.         [ "$VERBOSE" = no ] || log_action_end_msg $ES
  81.     fi
  82.     ;;
  83.   restart|force-reload)
  84.      /etc/init.d/bootlogd stop
  85.      /etc/init.d/bootlogd start
  86.     ;;
  87.   status)
  88.     status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  89.     ;;
  90.   *)
  91.     echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload|status}" >&2
  92.     exit 3
  93.     ;;
  94. esac
  95.  
  96. :
  97.